package qunartest02;

import com.google.common.collect.Lists;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;

public class ReturnNull {

    static ExecutorService executorService = Executors.newCachedThreadPool();

    public static void main(String[] args) {
        List<Future<Boolean>> futures = Lists.newArrayList();
        ArrayList<ActivityBean> arrayList = Lists.newArrayList();
        for (int i = 0; i < 1000; i++) {
            int finalI = i;
            ActivityBean activityBean = new ActivityBean();
            futures.add((Future<Boolean>) executorService.submit(() -> {
                activityBean.setName("abc");
                arrayList.add(activityBean);
            }));
        }
        FuturesUtil.getNullIfTimeOut(futures, 0, TimeUnit.MILLISECONDS);
        if (arrayList.contains(null)) {
            System.out.println("list 包含 null 值");
            int index = arrayList.indexOf(null);
            System.out.println(index);
            System.out.println(arrayList);
        }
    }

    static class ActivityBean {
        String name;

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }
    }
}
